<!-- **i18n版本-->
<template>
  <el-dialog :close-on-click-modal="false" :visible.sync="showDialog" :title="title" width="75%">
    <el-form ref="form" :model="form" size="small" label-width="120px">
      <el-row :gutter="10">
        <el-col :xs="24" :sm="20" :md="6" :lg="6" :xl="6">
          <!--设备型号ID -->
          <el-form-item :label="tf('deviceModelId')" prop="deviceModelId">
            <el-input v-model="form.deviceModelId" />
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="20" :md="6" :lg="6" :xl="6">
          <!--设备名称 -->
          <el-form-item :label="tf('deviceName')" prop="deviceName">
            <el-input v-model="form.deviceName" />
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="20" :md="6" :lg="6" :xl="6">
          <!--机构代码 -->
          <el-form-item :label="tf('orgCode')" prop="orgCode">
            <el-input v-model="form.orgCode" />
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="20" :md="6" :lg="6" :xl="6">
          <!--所属机构 -->
          <el-form-item :label="tf('orgName')" prop="orgName">
            <el-input v-model="form.orgName" />
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="20" :md="6" :lg="6" :xl="6">
          <!--设备ip -->
          <el-form-item :label="tf('deviceIp')" prop="deviceIp">
            <el-input v-model="form.deviceIp" />
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="20" :md="6" :lg="6" :xl="6">
          <!--设备mac地址 -->
          <el-form-item :label="tf('macAddress')" prop="macAddress">
            <el-input v-model="form.macAddress" />
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="20" :md="6" :lg="6" :xl="6">
          <!--日志级别 -->
          <el-form-item :label="tf('logLevel')">
            <el-input v-model="form.logLevel" />
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="20" :md="6" :lg="6" :xl="6">
          <!--启用标志 -->
          <el-form-item :label="tf('enableFlag')" prop="enableFlag">
            <Dictionary v-model="form.enableFlag" :updata-dict="form.enableFlag + ''" :dict-key="'FILTER_FLAG'" />
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="20" :md="6" :lg="6" :xl="6">
          <!--删除标志 -->
          <el-form-item :label="tf('deleteFlag')">
            <Dictionary v-model="form.deleteFlag" :updata-dict="form.deleteFlag + ''" :dict-key="'DELETE_FLAG'" />
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="20" :md="6" :lg="6" :xl="6">
          <!--更新人 -->
          <el-form-item :label="tf('updateBy')">
            <el-input v-model="form.updateBy" />
          </el-form-item>
        </el-col>
        <el-col :xs="24" :sm="20" :md="6" :lg="6" :xl="6">
          <!--更新时间 -->
          <el-form-item :label="tf('updateTime')">
            <el-input v-model="form.updateTime" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <DeviceLogDetailPreviewItem ref="deviceLogDetail" alias="r0" :module="module" />
    <DeviceModelPreviewItem ref="deviceModel" alias="r1" :module="module" />

    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="close()">{{ $t('btn.close') }}</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { preview } from '@/api/deviceInfo'
import DeviceLogDetailPreviewItem from '@/views/deviceLogDetail/component/previewItem'
import DeviceModelPreviewItem from '@/views/deviceModel/component/previewItem'
import Dictionary from '@/components/Dictionary/index'
import i18nHandler from '@/mixins/i18nHandler'

export default {
  name: 'DeviceInfoDetail',
  components: {
    Dictionary,
    DeviceLogDetailPreviewItem,
    DeviceModelPreviewItem,
  },
  mixins: [i18nHandler],
  props: {
    module: String,
  },
  data() {
    return {
      showDialog: false,
      title: '',
      dictionarys: [],
      form: {},
      i18nQry: {},
    }
  },
  created() {
    this.i18nQry.module = this.module
  },
  methods: {
    close() {
      this.showDialog = false
      this.form = {}
    },

    init() {
      preview({ id: this.form.id, accessKey: this.form.accessKey })
        .then((data) => {
          this.form = data.data
          this.$refs.deviceLogDetail.detail = this.form.deviceLogDetails
          this.$refs.deviceModel.detail = this.form.deviceModels
        })
        .catch(() => {})
    },
  },
}
</script>

<style scoped></style>
